#pragma once
#include <semaphore.h>
#include <atomic>
#include <memory>
#include <string>
#include <thread>

class SocketClient {
public:
    SocketClient(int clientFd);
    ~SocketClient();

    int GetFd() { return clientFd_; }
    void RunTask(const std::string &message);

private:
    void RunTaskMain();

    int clientFd_ = -1;
    std::atomic<bool> running_;
    std::unique_ptr<std::thread> thread_ = nullptr;
    sem_t commandSem_;
    std::string currentCommand_ = "";
};
